package com.bjsxt.controller.doctor;

import com.bjsxt.controller.BaseController;
import com.bjsxt.domain.Patient;
import com.bjsxt.domain.PatientFile;
import com.bjsxt.dto.PatientDto;
import com.bjsxt.service.PatientService;
import com.bjsxt.vo.AjaxResult;
import com.bjsxt.vo.DataGridView;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:liao
 * @Description:TODO
 * @date:2021/1/14
 */
@RestController
@RequestMapping("/doctor/patient/")
public class PatientController extends BaseController {

    @Reference
    private PatientService patientService;

    /**
     * 分页查询所有的患者信息
     * @param patientDto
     * @return
     */
    @GetMapping("listPatientForPage")
    @HystrixCommand
    public AjaxResult listPatientForPage(PatientDto patientDto){
        DataGridView dataGridView = this.patientService.listPatientForPage(patientDto);
        return AjaxResult.success("查询成功",dataGridView.getData(),dataGridView.getTotal());
    }

    /**
     * 根据患者ID查询患者信息
     */
    @GetMapping("getPatientById/{patientId}")
    @HystrixCommand
    public AjaxResult getPatientById(@PathVariable String patientId){
        Patient patient = this.patientService.getPatientById(patientId);
        return AjaxResult.success(patient);
    }

    /**
     * 根据患者id查询患者档案信息
     */
    @GetMapping("getPatientFileById/{patientId}")
    @HystrixCommand
    public AjaxResult getPatientFileById(@PathVariable String patientId){
        PatientFile patientFile = this.patientService.getPatientFileById(patientId);
        return AjaxResult.success(patientFile);
    }


}
